package metrics

import (
	"fmt"
	"time"

	prometheusmetrics "github.com/deathowl/go-metrics-prometheus"
	"github.com/gin-gonic/gin"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"github.com/rcrowley/go-metrics"
)

func init() {
	fmt.Println("---init Automatic execution---")
	InitBodyStore()
}

func Router(router *gin.Engine) {
	prometheusClient := prometheusmetrics.NewPrometheusProvider(
		metrics.DefaultRegistry, "test", "go_skill_point_project", prometheus.DefaultRegisterer, 1*time.Second)
	go prometheusClient.UpdatePrometheusMetrics()
	router.GET("/metrics", func(ctx *gin.Context) {
		promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}).ServeHTTP(ctx.Writer, ctx.Request)
	})
}
